<?php

namespace App\Models\Admin;


use App\Models\AdminUserRole;
use App\Models\File;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Tymon\JWTAuth\Contracts\JWTSubject;

class AdminUser extends Authenticatable implements JWTSubject
{
    use Notifiable;
    use SoftDeletes;

    protected $table = 'admin_user';


    protected $fillable = [
        'username', 'password', 'name', 'avatar', 'status'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function getJWTIdentifier()
    {
        return $this->getKey();
    }


    public function getJWTCustomClaims()
    {
        return [];
    }

    /**
     * 头像
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function file(){
        return $this->hasOne(File::class,'id','avatar');
    }

    /**
     * 用户权限
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user_role(){
        return $this->hasOne(AdminUserRole::class,'user_id','id');
    }
}
